// 无用
import { useRequest } from "ahooks";
import { getUserInfoService } from "../services/user";
import { useDispatch } from "react-redux";
import { loginReducer } from "../store/userInfoReducer";

function useLoadUserData() {
  const dispatch = useDispatch();

  const { loading } = useRequest(getUserInfoService, {
    onSuccess(result) {
      const { userId, userName, nickName, isAdmin } = result;
      dispatch(loginReducer({ userId, userName, nickName, isAdmin }));
    },
  });
  return { loading };
}

export default useLoadUserData;
